package com.echoplots.echoplotsspringbootstart.controller;

import com.echoplots.echoplotsspringbootstart.bean.XmlBeanTest;
import com.echoplots.echoplotsspringbootstart.properties.EchoPlotsBean;
import com.echoplots.echoplotsspringbootstart.properties.EchoPlotsConfigBean;
import com.echoplots.echoplotsspringbootstart.properties.EchoPlotsProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author cos
 * @description desc
 * @date 2020/11/18
 */
@RestController
public class IndexController {
    @Autowired
    private EchoPlotsProperties echoPlotsProperties;

    @Autowired
    private EchoPlotsBean echoPlotsBean;

    @Autowired
    private EchoPlotsConfigBean echoPlotsConfigBean;

    @Autowired
    private XmlBeanTest xmlBeanTest;
    //自定义属性Test
    @RequestMapping("/")
    public String index() {
        return echoPlotsProperties.getName();
    }


    //多自定义属性Test
    @RequestMapping("/bean")
    public String indexBean() {
        return echoPlotsBean.getName()+"###" +echoPlotsBean.getDesc();
    }


    //属性间引用Test
    @RequestMapping("/title")
    public String title() {
        return echoPlotsBean.getTitle();
    }


    //自定义配置文件echoplots.properties Test
    @RequestMapping("/properties")
    public String properties() {
        return "姓名："+echoPlotsConfigBean.getName()+" 年龄："+echoPlotsConfigBean.getAge();
    }


    //自定义配置文件echoplots.properties Test
    @RequestMapping("/xml")
    public String xml() {
        return xmlBeanTest.getName();
    }
}
